package org.carabiner.infopanel;

import java.awt.Component;

import javax.swing.Icon;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;

/**
 * The icon node class was written by Nobuo Tamemasa and can be found at
 * http://www.codeguru.com/java/articles/187.shtml.
 * 
 * <p>
 * Carabiner Testing Framework
 * </p>
 * 
 * <p>
 * Copyright: <a href="http://www.gnu.org/licenses/gpl.html">GNU Public License</a>
 * </p>
 * 
 */
class IconNodeRenderer extends DefaultTreeCellRenderer
{
  public Component getTreeCellRendererComponent(JTree tree, Object value,
      boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus)
  {

    super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row,
        hasFocus);

    Icon icon = ((CarabinerComponentNode) value).getIcon();

    if (icon != null)
    {
      setIcon(icon);
    }

    return this;
  }

}
